package com.ericom.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name = "product_comment")
public class ProductComment extends BaseObject {
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("id", id)
				.append("title", title).append("description", description)
				.append("member", member).append("product", product)
				.append("commentDate", commentDate).toString();
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof ProductComment))
			return false;
		ProductComment castOther = (ProductComment) other;
		return new EqualsBuilder().append(id, castOther.id)
				.append(title, castOther.title).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(id).append(title).toHashCode();
	}

	@Column(name = "comment_date")
	public String getCommentDate() {
		return commentDate;
	}

	public void setCommentDate(String commentDate) {
		this.commentDate = commentDate;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "member_id")
	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	@ManyToOne(cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "product_id")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	private Long id;
	private String title;
	private String description;
	private Member member;
	private Product product;
	private String commentDate;

}
